GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( d2dcf4...7dc89d )
by butschster
06:01
created

datatables.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 50
rs 9.3333

2 Functions

Rating   Name   Duplication   Size   Complexity  
A datatables.js ➔ ... ➔ ??? 0 5 1
A datatables.js ➔ ... ➔ $.fn.dataTable.ext.order[DateTime] 0 5 1
1
Admin.Modules.add('display.datatables', () => {
0 ignored issues
show
Bug introduced by
The variable Admin seems to be never declared. If this is a global, consider adding a /** global: Admin */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2
    $.fn.dataTable.ext.errMode = () => {
3
        Admin.Messages.error(
0 ignored issues
show
Bug introduced by
The variable Admin seems to be never declared. If this is a global, consider adding a /** global: Admin */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
4
            i18next.t('lang.table.error')
0 ignored issues
show
Bug introduced by
The variable i18next seems to be never declared. If this is a global, consider adding a /** global: i18next */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
5
        )
6
    };
7
8
    $.fn.dataTable.ext.order['DateTime'] = function (settings, col) {
9
        return this.api().column(col, {order: 'index'}).nodes().map((td, i) => {
0 ignored issues
show
Unused Code introduced by
The parameter i is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
10
            return $(td).data('value');
11
        });
12
    }
13
14
    $('.datatables').each((i, item) => {
15
        var $this = $(item),
16
            id = $this.data('id');
17
18
        var params = $this.data('attributes');
19
20
        var url;
21
        if (url = $this.data('url')) {
22
            params.serverSide = true;
23
            params.processing = true;
24
            params.ajax = {
25
                url: url,
26
                data (d) {
27
                    $('[data-datatables-id="' + id + '"] .column-filter[data-type]').each((i, subitem) => {
28
                        var $this = $(subitem);
29
                        var index = $this.closest('td').data('index');
30
                        if (name = $this.data('ajax-data-name')) {
0 ignored issues
show
Bug introduced by
The variable name seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.name.
Loading history...
31
                            d.columns[index]['search'][name] = $this.val();
32
                        }
33
                    });
34
                }
35
            };
36
        }
37
38
        var table = $this.DataTable(params);
39
40
        $('[data-datatables-id="' + id + '"] .column-filter[data-type]').each((i, item) => {
41
            var $this = $(item),
42
                type = $this.data('type'),
43
                index = $this.closest('td').data('index');
44
45
            if (_.isFunction(window.columnFilters[type])) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
46
                window.columnFilters[type](item, table.api(), table.api().column(index), index);
47
            }
48
        });
49
    });
50
});
51
52
window.columnFilters = {
53
    range (container, table, column, index) {
54
        let $container = $(container),
55
            from = $('input:first', $container),
56
            to = $('input:last', $container);
57
58
        var isDateRange = false;
59
60
        from.data('ajax-data-name', 'from');
61
        to.data('ajax-data-name', 'to');
62
63
        from
64
            .add(to)
65
            .on('keyup change', function () {
66
                table.draw();
67
            });
68
69
        if (from.closest('.input-date').length > 0 && to.closest('.input-date').length > 0) {
70
            from.closest('.input-date')
71
                .add(to.closest('.input-date'))
72
                .on('dp.change', function () {
73
                    table.draw();
74
                });
75
76
            isDateRange = true;
77
        }
78
79
        let checkDateRange = (from, to, value) => {
80
            let fromValue = from.val(),
81
                toValue = to.val();
82
83
            if (fromValue != '') {
84
                fromValue = from.closest('.input-date').data('DateTimePicker').date();
85
            } else {
86
                fromValue = undefined;
87
            }
88
89
            if (toValue != '') {
90
                toValue = to.closest('.input-date').data('DateTimePicker').date();
91
            } else {
92
                toValue = undefined;
93
            }
94
95
            value = moment(value, from.data('date-format'));
96
97
            if(!_.isObject(fromValue) && !_.isObject(toValue)) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
98
                return true;
99
            }
100
101
            if (!value.isValid()) {
102
                return false;
103
            }
104
105
            if (!_.isObject(fromValue) && value.isSameOrBefore(toValue)) {
106
                return true;
107
            }
108
109
            if(!_.isObject(toValue) && value.isSameOrAfter(fromValue)) {
110
                return true;
111
            }
112
113
            return value.isBetween(fromValue, toValue)
114
        }
115
116
        let checkNumberRange = (from, to, value) => {
117
            let fromValue = parseInt(from.val()),
118
                toValue = parseInt(to.val());
119
120
            value = parseInt(value);
121
122
            if(_.isNaN(fromValue) && _.isNaN(toValue)) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
123
                return true;
124
            }
125
126
            if(_.isNaN(value)) {
127
                return false;
128
            }
129
130
            if(_.isNaN(fromValue) && value <= toValue) {
131
                return true;
132
            }
133
134
            if( _.isNaN(toValue) && value >= fromValue) {
135
                return true;
136
            }
137
138
            return value >= fromValue && value <= toValue;
139
        }
140
141
        $.fn.dataTable.ext.search.push((settings, data, dataIndex) => {
0 ignored issues
show
Unused Code introduced by
The parameter dataIndex is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
142
            if (table.settings()[0].sTableId != settings.sTableId) {
143
                return true;
144
            }
145
146
            let value = data[index];
147
148
            if (value && !_.isUndefined(value['@data-order'])) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
149
                value = value['@data-order'];
150
            }
151
152
            if (isDateRange) {
153
                return checkDateRange(from, to, value)
154
            }
155
156
            return checkNumberRange(from, to, value)
157
        });
158
    },
159
    select (input, table, column, index) {
0 ignored issues
show
Unused Code introduced by
The parameter index is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
160
        var $input = $(input);
161
162
        $input.on('change', () => {
163
            let val = $input.val() ? $input.find(':selected').text() : '';
164
            column.search(val).draw()
165
        });
166
    },
167
    text (input, table, column, index) {
0 ignored issues
show
Unused Code introduced by
The parameter index is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
168
        var $input = $(input)
169
170
        $input.on('keyup change', () => {
171
            column.search($input.val()).draw();
172
        })
173
    }
174
}